<?php

class Core_Backend_Component_Website_View_Menu_Index extends Core_Backend_Share_View_Grid {
    public function  __construct() {
        parent::__construct();
    }

    protected function  buildNavigation($navigation) {
        $navigation->addLabel($this->__('website.title.menu_index'));
        parent::buildNavigation($navigation);
    }

    protected function  buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(array('areaid'=>$this->getCurrentAreaId()), 'create'), $this->__('share.button.create'));
    }

    public function  buildGrid($grid) {
    	$this->getTemplate()->assignMulti(array('areas'=>$this->getAreas(), 'current_area_id'=>$this->getCurrentAreaId()));
        $grid->setId('menu_grid')
                ->setPrimaryKey('id')
                ->setSortField($this->getRequest()->getQuery('sort', 'id'))
                ->setSortDirection($this->getRequest()->getQuery('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('share.label.name'),'name','{name}')
                ->setSortField('name');
        $grid->addLabelColumn($this->__('share.label.url'),'url','{url}')
                ->setSortField('url');
        $grid->addLabelColumn($this->__('share.label.sef_url'),'sel_url','{sef_url}')
                ->setSortField('sef_url');
        $grid->addLabelColumn($this->__('share.label.enable'), 'enabled', '{enabled}')
                ->setSortField('enabled')
                ->setWidth(50)
                ->setAlign('center');
        $grid->addLabelColumn($this->__('global.label.level'),'level','{level}')
                ->setSortField('level')
                ->setWidth(40)
                ->setAlign('center');
        $grid->addLabelColumn($this->__('share.label.sorting'),'sorting','{sorting}')
                ->setWidth(40)
                ->setAlign('center');
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->addLinkColumn('#', 'sort', $this->getUrl(array('parent' => '{parent_id}'), 'sort'), $this->__('share.button.sort'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $pagination->setUrlFormat($this->getPaginationUrl())->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }
}

